<template>
  <div>
    <!-- <el-dialog
      title="选择仓库后导入订单"
      :visible.sync="chooseVisible"
      class="el-dialog-small pad-none"
    >
      <div class="form-detail">
        <div class="form-body plr-10">
          <el-form
            ref="form"
            :model="form"
            :rules="rules"
            label-width="120px"
            label-position="left"
            label-suffix=":"
          >
            <el-form-item :label="$t('common.selectWare')">
              <el-select v-model="warehouseId" :placeholder="$t('common.placeholderSelect')">
                <el-option
                  v-for="item in wmsWarehouseList"
                  :key="item.id"
                  :label="item.warehouseName"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
      </div>

      <span slot="footer" class="dialog-footer">
        <el-button @click="chooseVisible = false">{{ $t('common.cancel') }}</el-button>
        <el-button :loading="loading" type="primary" @click="submit('form')"
          >确定并导入订单</el-button
        >
      </span>
    </el-dialog> -->
    <!-- 导入订单 -->
    <ImportFile
      ref="ImportFileRef"
      :title="$t('order.import')"
      :actionUrl="'/productShop/importExcel'"
      :params="{
        warehouseId: warehouseId[0] ? warehouseId[0] : warehouseId,
        cabinetNum: cabinetNum,
        areaId: warehouseId[1] ? warehouseId[1] : null,
      }"
      tempalteUrl="https://zjyg-yt.oss-cn-hangzhou.aliyuncs.com/scm/upload/20231009/xlsx/9820a47f53b04841999a97d09d2e3009/入库单箱子导入模板1009.xlsx"
      @success="successOrder"
    />
  </div>
</template>
<script>
import { listWmsWarehouse } from "@/api/wms/warehouse";
import ImportFile from "@/components/Upload/ImportFile.vue";
export default {
  props: ['warehouseId', 'cabinetNum'],
  components: { ImportFile },
  data() {
    return {
      chooseVisible: false,
      loading: false,
      columns: [
        {
          prop: "warehouseId",
          label: this.$t('common.selectWare'),
          col: 24,
          type: "remoteSelect",
          selectOptions: {
            url: "/wmsWarehouse/list",
            searchStr: "warehouseName",
            returnStr: "data",
            data: {},
            method: "POST",
            optionsValue: "id",
            optionsLabel: "warehouseName",
            optionsKey: "id",
          },
        },
      ],
      rules: {
        warehouseId: [{ required: true, message: this.$t('common.placeholderSelect') }],
      },
      form: {
        warehouseId: "",
        serviceType: "SHIPPING",
      },
      warehouseId: null,
      wmsWarehouseList: []
    };
  },
  methods: {
    open() {
      this.chooseVisible = true;
    },
    /** 查询仓库列表 */
    getWareHouseList() {
      this.selectedWarehouseId = null
      const query = {
        ...this.queryParams,
        pageNum: undefined,
        pageSize: undefined,
      };
      const pageReq = undefined;
      listWmsWarehouse(query, pageReq).then((response) => {
        const { content, totalElements } = response;
        this.wmsWarehouseList = content;
        this.setChildren();
        this.loadAreas()
      });
    },
    submit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.openOdder();
        } else {
          return false;
        }
      });
    },
    successOrder() {
      this.chooseVisible = false;
      this.$emit("success");
    },
    openOdder() {
      this.$refs.ImportFileRef.open();
    },
  },
};
</script>
